package com.timecheck.pojo;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DataResult {

    /* 数据请求成功状态码*/
    public static final int STA_SUC = 200;    //处理成功
    public static final int STA_FIN_SUC = 201;	//认证成功且完成
    public static final int STA_NOT_SSO_PERMISSION = 202;	//运维角色触发时间地址策略不能单点登录
    public static final int STA_OBJ_NOT_EXIST = 210;    //处理成功, 但未数据不存在
    public static final int STA_IGNORE = 220;    //忽略操作

    /*执行中*/
    public static final int STA_EXECUTING = 300;    //正在处理

    /*客户端异常状态码*/
    public static final int STA_EXCEPTION_PARAM_ERR = 405;    //参数异常
    public static final int STA_EXCEPTION_NOT_FOUND = 404;    //参数异常
    public static final int STA_EXCEPTION_REQ_TIMEOUT = 408;    //请求异常， 请求超时

    /*服务端异常状态码 550-599为公有状态码  610-699为私有状态码 */
    public static final int STA_EXCEPTION = 500;    //服务端处理异常

    public static final int STA_EXCEPTION_DUPLICATE_ENTRY = 550;    //信息重复
    public static final int STA_EXCEPTION_DATABASE_TIMEOUT = 553;	//数据库连接超时
    public static final int STA_EXCEPTION_PERMISSION_LOAD = 558;   //权限加载失败
    public static final int STA_EXCEPTION_PERMISSION_DENIED = 559;   //越权访问
    public static final int STA_TIMEOUT = 600;
    public static final int STA_EXCEPTION_ORGCODE_NOT_FOUND = 610;	//无法获取组code
    public static final int STA_POLICY_CHECKSUM_FAILED = 611;    //口令策略校验不通过
    public static final int STA_NUM_OF_HISTORY_CHECKSUM_FAILED = 6111;    //口令历史次数校验不通过
    public static final int STA_USER_NAME_CHECKADMIN_FAILED = 621;    //用户名称校验不能是超管

    public static final int STA_EXCEPTION_ORGCODE_GROUP_IS_EXISTS = 622; //当前组下含有子组编码信息，删除失败
    public static final int STA_EXCEPTION_ORGCODE_USER_IS_EXISTS = 623;    //当前组下含有用户信息，删除失败
    public static final int STA_EXCEPTION_ORGCODE_RES_IS_EXISTS = 624;    //当前组下含有资源信息，删除失败
    public static final int STA_EXCEPTION_ORGCODE_ROLE_IS_EXISTS = 625;    //当前组下含有角色信息，删除失败
    public static final int STA_EXCEPTION_ORGCODE_RESROLE_IS_EXISTS = 626;    //当前组下含有运维角色信息，删除失败
    public static final int STA_USER_CLIENT_CA_CREATE_FAILED = 631;    //客户端证书创建失败

    public static final int STA_AUTH_FAILED = 650;	//认证失败
    public static final int STA_4A_AUTH_FAILED = 6501;	//4A认证失败,根据4A返回的账号信息未找到对应的主账号
    public static final int STA_AUTH_MODE_FAILED = 651;	//获取认证方式失败
    public static final int STA_AUTH_TIMEOUT_FAILED = 6511;//认证信息超时
    public static final int STA_GET_TOKEN_FAILED = 652;	//获取认证凭据时发生异常
    public static final int STA_SEC_RANDOM_REGION_FAILED = 653; //滑块未能移动到指定区域
    public static final int STA_OTP_AUTH_FAILED = 654;	//OTP口令错误
    public static final int STA_AD_AUTH_FAILED = 655;	//AD口令错误
    public static final int STA_CA_AUTH_FAILED = 656;	//证书认证失败
    public static final int STA_CA_SERVICE_CONFIG_LOAD_FAILED = 6561;	//证书服务加载失败
    public static final int STA_CA_SERVICE_NOT_OPEN = 6562;	//证书服务未开启
    public static final int STA_CA_CHAR_MATCH_ERR = 6563;	//请填写匹配字符
    public static final int STA_SSO_USER_OPERATION_AUYH_FAILED = 6564; //sso用户操作权限校验失败

    public static final int STA_USER_INFO_ERROR = 657;	//用户认证信息被篡改
    public static final int STA_USER_EXPIRED = 658; //临时用户，已到期，失效
    public static final int STA_USER_ACC_PWD_FAILED = 659;//用户名或口令错误
    public static final int STA_USER_ORG_PWD_AUTHC_FAILED = 6591; //原始口令认证错误
    public static final int STA_USER_WILL_LOCKED = 6592; //认证失败, 还有？次机会账号将被锁定
    public static final int STA_USER_INIT_PWD_NULL = 6593; //请先到[配置管理]中配置初始化固定口令
    public static final int STA_USER_RANDOM_PWD_NULL = 6594; //请先到[配置管理]中配置初始化随机口令规则
    public static final int STA_USER_CONFIG_PWD_NULL = 6595; //请先到[配置管理]中配置初始化信息
    public static final int STA_USER_CONFIG_EMAIL_NULL = 6596; //请先配置邮件地址后再尝试该操作

    public static final int STA_OTP_SERVICE_NOT_OPEN = 660;  //处理成功, OTP服务未开启
    public static final int STA_OTP_SERVICE_CONFIG_LOAD_FAILED = 661;  //处理成功, OTP服务配置加载失败
    public static final int STA_OTP_SERVICE_SECKEY_LOAD_FAILED = 662;  //处理成功, OTP服务加载seckey失败

    public static final int STA_AD_SERVICE_NOT_OPEN = 663;  //处理成功, AD服务未开启
    public static final int STA_AD_SERVICE_CONFIG_LOAD_FAILED = 664;  //处理成功, AD服务配置加载失败

    public static final int STA_USER_LOCKED = 665;	//处理成功, 用户已锁定
    public static final int STA_USER_LOCKDOWN = 6651;	//处理成功, 用户已禁闭
    public static final int STA_USER_DESTROY = 666;	//处理成功, 用户已注销
    public static final int STA_USER_FROZEN = 6661; // 处理成功，用户已冻结

    public static final int STA_IP_POLICY_CHECKED_FAILED = 667;	//处理成功, 地址策略校验失败
    public static final int STA_TIME_POLICY_CHECKED_FAILED = 668;	//处理成功, 时间策略校验失败

    public static final int STA_PASSWD_EXPIRED = 669;	//处理成功, 口令策略校验失败, 口令已过期
    public static final int STA_PASSWD_POLICY_CHECK_FAILED = 670;   //口令内容与口令策略要求不符, 口令策略已更新
    public static final int STA_PASSWD_STATUS_CHECK_FAILED = 671;   //口令状态为初始化
    //public static final int STA_PASSWD_LENGTH_CHECK_FAILED = 670;	//处理成功, 口令策略校验失败, 口令总长度不符合策略要求
    //public static final int STA_PASSWD_LOWERCASE_LENGTH_CHECK_FAILED = 671;	//处理成功, 口令策略校验失败, 口令包含大写字符长度不符合策略要求
    //public static final int STA_PASSWD_UPPERCASE_LENGTH_CHECK_FAILED = 672;	//处理成功, 口令策略校验失败, 口令包含小写字符长度不符合策略要求
    //public static final int STA_PASSWD_NUMBER_LENGTH_CHECK_FAILED = 673;	//处理成功, 口令策略校验失败, 口令包含数字长度不符合策略要求
    //public static final int STA_PASSWD_SPECIALCHARACTERS_EXPIRED = 674;	//处理成功, 口令策略校验失败, 口令包含特殊字符长度不符合策略要求
    //public static final int STA_PASSWD_KEYWORD_CHECK_FAILED = 675;	//处理成功, 口令策略校验失败, 口令包含禁用关键字

    public static final int STA_PASSWD_WILL_EXPIRED = 676; //处理成功, 口令将会在3天内到期, 请及时修改口令

    public static final int STA_USER_TEMP_NOT_BEGIN_EXPIRED = 677; //处理成功, 临时用户登录失败, 临时用户设定时间还未开始
    public static final int STA_USER_TEMP_HAS_END_EXPIRED = 678; //处理成功, 临时用户登录失败, 临时用户设定时间已结束

    public static final int STA_NO_ADMITTED_PLATFORMS = 680;    //无平台权限或加载平台权限异常
    public static final int STA_NO_REGISTER_TICKET_FAILED = 681;    //认证中心注册登录认证票据时出现异常

    public static final int STA_EMAIL_SEND_SUCCESS = 685; //邮件发送成功
    public static final int STA_EMAIL_SEND_FAILD = 686; //邮件发送失败

    public static final int STA_SMS_SERVICE_NOT_OPEN = 687;  //处理成功, 短信认证服务未开启
    public static final int STA_SMS_SERVICE_CONFIG_LOAD_FAILED = 688;  //短信认证服务配置加载失败
    public static final int STA_SMS_SERVICE_CONFIG_GAIN_FAILED = 689;  //验证码获取失败，请检查短信服务配置或用户相关配置
    public static final int STA_SMS_SERVICE_CONFIG_AUTH_FAILED = 690;  //短信认证失败，请输入正确的验证码
    public static final int STA_SMS_SERVICE_CONFIG_GAIN_LIMIT_FAILED = 691;  //验证码获取失败，短信发送频率超限
    public static final int STA_SMS_SERVICE_CONFIG_GAIN_SERVER_FAILED = 692;  //验证码获取失败，请求异常

    //邮件验证
    public static final int STA_EMAIL_SERVICE_CONFIG_AUTH_FAILED = 693;  //邮件认证失败，请输入正确的验证码
    public static final int STA_EMAIL_SERVICE_CONFIG_GAIN_LIMIT_FAILED = 6931;  //验证码获取失败，邮件发送频率超限
    public static final int STA_EMAIL_SERVICE_CONFIG_GAIN_SERVER_FAILED = 6932;  //验证码获取失败，请求异常
    public static final int STA_ADMIN_USER_AUTHC = 6933;  //当前为超级管理员验证，只验证静态口令
    public static final int STA_COMMON_USER_AUTHC = 6934;  //普通用户，验证静态口令

    // -------------------------------------------------------------------------系统参数(700-760)-----------------------------------------------------------------------
    public static final int STA_SETTINGS_DATASOURCE_ERR = 700;  //数据库连接异常
    public static final int STA_SETTINGS_BACKUP_FILE_EXIST = 701;  //备份文件已存在
    public static final int STA_SETTINGS_NO_SUCH_ALGORITHM = 702;  //没有该算法
    public static final int STA_SETTINGS_RESTORE_FAILD = 703;  //还原失败
    public static final int STA_SETTINGS_SIGN_NOT_VALID = 704;  //文件签名不合法
    public static final int STA_SETTINGS_EXECUTE_SQL_FAILD = 705;  //SQL执行失败
    public static final int STA_SETTINGS_DATE_PARSE_ERR = 706;  //日期解析异常
    public static final int STA_SETTINGS_BACKUP_FILE_FORMAT_ERR = 707;  //升级包被篡改或格式错误
    public static final int STA_SETTINGS_SERVICE_EMAIL_NOT_OPEN = 720;  //邮件服务尚未开启
    public static final int STA_SETTINGS_SERVICE_SYSLOG_NOT_CONFIG = 721;  //请先配置syslog内容

    public static final int STA_SETTINGS_DATASYNV_PUSH_PARAM_NUM_ERR = 730;  //执行异常，请检查参数个数
    public static final int STA_SETTINGS_DATASYNV_PUSH_PARAM_ERR = 731;  //执行异常，请检查参数是否正确


    // -------------------------------------------------------------------------资源管理(760-799)-----------------------------------------------------------------------
    public static final int STA_LIC_RES_NUM_LIMITED = 760;  //资源数量已达到上限
    public static final int STA_RESTYPE_NOT_FOUND = 761;  //资源类型未找到
    public static final int STA_DELETE_ONLINE_RESOURCE = 762; //无法删除在线资源
    public static final int STA_ADD_RESOURCE_EXIST = 763;   //添加的资源已存在
    public static final int STA_RESOURCE_UNREACHABLE = 764;   //资源不可达

    public static final int STA_UNLOCK_PASSWD_FAIL = 765; // 重置解锁普通账号失败

    public static final int STA_DELETE_CSTATUS_ACC = 766; // 删除纳管账号

    public static final int STA_ADMIN_ACC_TEST_FAIL = 767; // 管理员账号拨测失败

    public static final  int STA_NO_EXEC = 768; // 未执行

    public static final  int STA_MANAGE_LEVEL_NO = 769; // 不接管状态清单


    // -------------------------------------------------------------------------账号管理(800-879)--------------------------------------------------------------------------
    public static final int SAT_CONNECTION_ACC_PWD_CONFLICTED = 801;   //连接账号口令冲突，设置口令数据库存储不一致（在账号管理以外的地方设置口令）
    public static final int SAT_SU_ACC_PWD_CONFLICTED = 802;   //提权账号口令冲突，设置口令数据库存储不一致（在账号管理以外的地方设置口令）
    public static final int SAT_CONNECTION_AND_SU_ACC_PWD_CONFLICTED = 803;   //801 和 802

    public static final int STA_ACC_CREDENTIAL_STATUS_ERR = 805;    //账号口令状态异常，账号表与账号口令表的数据不一致
    public static final int STA_ACC_CREDENTIAL_NOT_FOUND = 806;    //账号口令异常，请求数据中未携带口令信息，并且数据库中有认证信息记录，但未找到该账号的口令信息
    public static final int STA_RESTYPE_DRIVER_NOT_FOUND = 851; //资源类型绑定的驱动未找到

    // -------------------------------------------------------------------------驱动错误码(880-900)-----------------------------------------------------------------------
    //驱动未知错误
    public static final int STA_DRIVER_UNKNOW_EXCEPTION = 900;

    //驱动参数错误
    public static final int STA_DRIVER_ARGS_ERROR = 880;

    //驱动命令未找到
    public static final int STA_DRIVER_COMMAND_NOT_FOUND = 881;

    //驱动无法打开文件
    public static final int STA_DRIVER_OPEN_FAILED = 882;

    //驱动执行异常
    public static final int STA_DRIVER_EXECUTE_EXCEPTION = 883;

    //驱动不支持该命令
    public static final int STA_DRIVER_NOT_SUPPORT = 884;

    //驱动命令执行失败
    public static final int STA_DRIVER_FAILED = 885;

    //驱动改密失败
    public static final int STA_DRIVER_CHANGE_PASSWD_FAILED = 886;

    //驱动密码错误或密码提示符错误
    public static final int STA_DRIVER_PASSWD_OR_PROMPT_FAILED = 887;

    //驱动操作用户不存在
    public static final int STA_DRIVER_USER_NOT_EXIST = 888;

    //远程驱动连接失败
    public static final int STA_REMOTE_DRIVER_CONNECT_FAILED = 891;

    // -------------------------------------------------------------------------计划任务(901-939)-----------------------------------------------------------------------
    /* 系统调度---计划内容不完整, 例如没有计划执行时间等 */
    public static final int STA_SCHEDULE_TASK_MISSING_DATA = 901;

    /* 系统调度---启动任务 */
    public static final int STA_SCHEDULE_START = 902;

    /* 系统调度---停止任务 */
    public static final int STA_SCHEDULE_STOP = 903;

    /* 系统调度---暂停任务 */
    public static final int STA_SCHEDULE_PAUSE = 904;

    /* 系统调度---计划已启动或运行中 不允许修改 */
    public static final int STA_SCHEDULE_NOT_ALLOW_MOD = 905;

    // -------------------------------------------------------------------------SSO(940-999)-----------------------------------------------------------------------
    /* SSO 注册票据失败 */
    public static final int STA_SSO_REGISTER_TICKET_ERR = 941;

    /* SSO 登录账号信息未找到 */
    public static final int STA_SSO_ACC_NOT_FOUND = 942;

    /* sso 违反访问策略 */
    public static final int STA_SSO_POLICY_DENY = 943;

    /* sso 不允许当前协议登录 */
    public static final int STA_SSO_PROTOCOL_DENY = 944;

    /* 工单关闭，不允许登录 */
    public static final int STA_WORKORDER_CLOSE_DENY = 945;

    /* 工单时间过期 */
    public static final int STA_WORKORDER_TIME_EXPORE =946;

    /* 工单信息不存在*/
    public static final int STA_WORKORDER_ID_EXPORE =947;

    /* 字符命令审批 无审批权限 */
    public static final int STA_CMD_APPROVAL_NO_PERMISSION =948;

    /* 个人授权状态 */
    public static final int STA_PERSONAL_AUTH_OVERDUE = 950;  //授权已过期
    public static final int STA_PERSONAL_AUTH_UNPLAYED = 951; //授权未开始

    /* 账号异地登录 */
    public static final int STA_ACCOUNT_REMOTE_LOGIN = 952;

    /* 个人授权不能加入分组 */
    public static final int STA_PERSONAL_AUTH_ENABLE_GROUP = 953;

    /* 拨测：连接账号口令过期， 过期改密：过期改密成功 */
    public static final int STA_MANAGER_ACCOUNT_PASSWD_EXPIRE = 954;
    // 连接账号拨测失败
    public static final int STA_SU_SUC_COMMON_SUC = 955;
    // su账号密码过期
    public static final int STA_SU_SUC_COMMON_FAILED = 956;
    // 提权账号口令正确不变更
    public static final int STA_SU_SELF_NOT_PASSWD = 957;
    // 账号口令正确
    public static final int STA_ACC_PASSWD_CORRECT = 968;

    public static final String STR_REDIRECT_HEADER = "Apollo-Redirect";
    public static final String STR_REDIRECT_PATH_HEADER = "Apollo-Redirect-Path";
    public static final String STR_LOGIN_EXPIRED = "Login-Expired";

    /* 数据响应状态 */
    private int status = STA_SUC;

    private String title;
    private String msgTitle;
    private String msg;
    private String detail;

    /* 处理完成时间 */
    private String dateTime = "1970-01-01 00:00";

    private Object meta;
    /**
     * 1.网络不通
     * 2.连接设备失败
     * 3.提权失败
     * 4.改密失败
     */
    private int stage;

    public DataResult() {
        this.dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
        this.msg = "";
    }

    public DataResult(String title) {
        this.dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
        this.title = title;
        this.msg = "";
    }


    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getMsgTitle() {
        return msgTitle;
    }

    public void setMsgTitle(String msgTitle) {
        this.msgTitle = msgTitle;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    public String getDateTime() {
        return dateTime;
    }

    public void setDateTime(String dateTime) {
        this.dateTime = dateTime;
    }

    public Object getMeta() {
        return meta;
    }

    public void setMeta(Object meta) {
        this.meta = meta;
    }

    public boolean isSuc() {
        return this.status == STA_SUC;
    }

    public boolean notExist() {
        return this.status == STA_OBJ_NOT_EXIST;
    }

    public int getStage() {
        return stage;
    }

    public void setStage(int stage) {
        this.stage = stage;
    }
}